#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

const int N = 1e5 + 10;
string s1;
int a[N], c[N], x;

int main()
{
	cin >> s1 >> x;
	int j = 1;
	for (int i = s1.size() - 1; i >= 0; i--)
	{
		a[j++] = s1[i] - '0';
	}
	int ma = s1.size();
	int ans = 0;
	for (int i = ma; i >= 1; i--)
	{
		ans = ans * 10 + a[i];
		c[i] = ans / x;
		ans = ans % x;
	}
	while (c[ma] == 0 && ma > 1)
	{
		ma--;
	}
	for (int i = ma; i >= 1; i--)
	{
		cout << c[i];
	}
	cout << endl << ans;
	return 0;
}